﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ErrorPage : System.Web.UI.Page
{

    protected String errorMessage;
    protected String errorType;
    protected String errorSourcePage;
    protected String stackTrace;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ScriptManager scriptManager = ScriptManager.GetCurrent(this);
            if (scriptManager != null)
            {
                if (scriptManager.Scripts != null)
                    scriptManager.Scripts.Clear();
                if (scriptManager.Services != null)
                    scriptManager.Services.Clear();
            }
        }
        if (!Page.IsPostBack)
        {
            //Extract the exception information from the session
            errorMessage = (String)Session["ErrorMessage"];
            errorType = (String)Session["ErrorType"];
            errorSourcePage = (String)Session["ErrorSourcePage"];
            stackTrace = (String)Session["StackTrace"];

            if (stackTrace != null)
            {
                stackTrace = stackTrace.Replace("\r\n", "<br/>");
            }

            if (String.IsNullOrEmpty(errorSourcePage))
            {
                errorSourcePage = Page.ClientQueryString;
            }

            //Clear the values from the session
            //Session["ErrorMessage"] = "";
            //Session["ErrorSourcePage"] = "";
            //Session["ExceptionType"] = "";
            //Session["StackTrace"] = "";

        }
    }
}
